package com.app.service;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.app.dao.CustomerMapper;
import com.app.entity.Customer;
import com.github.pagehelper.PageInfo;

@Service
public class CustomerServiceImpl implements CustomerService {
	@Autowired
	CustomerMapper customerMapper;

	public PageInfo<Customer> selectAllCustomer(Map<String, Object> queryMap) {
//		(一)PageHelper.startPage 静态方法调用
//		String start = String.valueOf(queryMap.get("start"));
//		String limit = String.valueOf(queryMap.get("limit"));
//		PageHelper.startPage(Integer.parseInt(start), Integer.parseInt(limit));
//		List<Customer> list = customerMapper.selectAll();
		
//		(二)使用参数方式，需要配置 supportMethodsArguments 参数为 true，同时要配置 params 参数
		List<Customer> list = customerMapper.selectAll(queryMap);
		
//		用PageInfo对结果进行包装װ
		PageInfo<Customer> pageInfo = new PageInfo<Customer>(list);
		return pageInfo;
	}
}
